fix a few warnings and an inappropriate attempt to free memory.
authortsteven4@gmail.com <tsteven4@gmail.com@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Sun, 9 Feb 2014 21:10:55 +0000 (21:10 +0000)
committertsteven4@gmail.com <tsteven4@gmail.com@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Sun, 9 Feb 2014 21:10:55 +0000 (21:10 +0000)
git-svn-id: http://gpsbabel.googlecode.com/svn/trunk@4728 f51c46e8-681c-474f-0cfe-069cfd0219fb

gpsbabel/pocketfms_wp.cc
gpsbabel/vecs.cc

index fc60a27f0a044938806edfb7186b7a9d98eae22c..3e9246f5f08f53ae1f7723511573a84acee0d725 100644 (file)
@@ -102,7 +102,6 @@ wr_init(const char* fname)
 static void
 enigma_waypt_disp(const Waypoint* wpt)
 {
-  char* t;
 #if NEW_STRINGS
   if (!wpt->shortname.isEmpty()) {
     // The output might have a space or control character.
@@ -112,7 +111,7 @@ enigma_waypt_disp(const Waypoint* wpt)
     // The output might have a space or control character.
     int i, l = strlen(wpt->shortname);
 #endif
-    t = (char*) xmalloc(l + 1);
+    char *t = (char*) xmalloc(l + 1);
     char* d = t;
     for (i = 0; i < l; i++) {
 #if NEW_STRINGS
@@ -125,11 +124,11 @@ enigma_waypt_disp(const Waypoint* wpt)
       }
     }
     *d = 0;
+    gbfprintf(file_out, "%s %f %f\n", t, wpt->latitude, wpt->longitude);
+    xfree(t);
   } else {
-    t = "NONAME";
+    gbfprintf(file_out, "%s %f %f\n", "NONAME", wpt->latitude, wpt->longitude);
   }
-  gbfprintf(file_out, "%s %f %f\n", t, wpt->latitude, wpt->longitude);
-  xfree(t);
 }
 
 static void
index ffa9421aa188bce2e71a3b3b618b81023ad9486a..7aed528444ea099aab5c385d7d75d8032d0cd74c 100644 (file)
@@ -1371,7 +1371,7 @@ GET_OPTION(const char* iarglist, const char* argname, DEBUG_PARAMS)
 get_option(const char* iarglist, const char* argname)
 #endif
 {
-  size_t arglen = strlen(argname);
+  const size_t arglen = strlen(argname);
   char* arglist;
   char* rval = NULL;
   char* arg;
@@ -1381,7 +1381,6 @@ get_option(const char* iarglist, const char* argname)
     return NULL;
   }
 
-  arglen = strlen(argname);
   arglist = xstrdup(iarglist);
 
   for (arg = arglist; argp = strtok(arg, ","), NULL != argp; arg = NULL) {